<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>4.2星期几</title>
</head>

<body>
    <script>
        var x = prompt("请输入0-6中的一个数字");
        // 注意数据类型要转化
        var y = parseInt(x);
        switch (y) {
            case 0:
                alert("星期日");
                break;
            case 1:
                alert("星期一");
                break;
            case 2:
                alert("星期二");
                break;
            case 3:
                alert("星期三");
                break;
            case 4:
                alert("星期四");
                break;
            case 5:
                alert("星期五");
                break;
            case 6:
                alert("星期六");
                break;
        }
    </script>
</body>

</html>